<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>03_案例练习-鼠标移入高亮显示</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }

            ul li{
                list-style: none;
            }

            a {
                text-decoration: none;
                color: black;
            }

            ul {
                width: 200px;
                height: 150px;
                border: 1px solid black;
                margin-left: 20px;
            }

            ul li {
                width: 200px;
                height: 50px;
                text-align: center;
                line-height: 50px;
                background-color: hotpink;
            }

            ul li:nth-child(2) {
                border-top: 1px solid #000;
                border-bottom: 1px solid #000;
                box-sizing: border-box;
            }

        </style>
    </head>
    <body>
        <ul>
            <li><a href="#">三合一</a></li>
            <li><a href="#">菠菜面</a></li>
            <li><a href="#">裤带面</a></li>
        </ul>


        <script>
            var li_list = document.querySelectorAll('li');

            for(var i = 0; i < li_list.length; i++){
                li_list[i].onmouseenter = function(){
                    this.style.backgroundColor = 'yellowgreen';
                }

                li_list[i].onmouseleave = function(){
                    this.style.backgroundColor = '';
                }
            }
        </script>
    </body>
</html>